package com.runjian.rundo.iot.agent.common.network.tcp.parser;

import com.runjian.rundo.iot.agent.common.network.tcp.config.TcpNetworkProperties;

import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.FixedLengthFrameDecoder;

/**
 * 固定长度解码器
 *
 * @author CaoQingHua
 */
public class FixedLengthPayloadParser implements PayloadParser {

    private final TcpNetworkProperties valueObject;

    public FixedLengthPayloadParser(TcpNetworkProperties valueObject) {
        this.valueObject = valueObject;
    }

    @Override
    public ByteToMessageDecoder getParser() {
        int size = valueObject.getFixedLength().getSize();
        return new FixedLengthFrameDecoder(size);
    }
}
